﻿using NfsCommon.Util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace MobileWeb.Controllers
{
    public class BaseController : ActionFilterAttribute
    {
        //表示是否检查登录 
        public bool IsCheck { get; set; }
        //Action方法执行之前执行此方法   
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {

            base.OnActionExecuting(filterContext);
            if (IsCheck)
            {
                //校验用户是否已经登录     
                if (checkLogin() == false)
                {
                    //跳转到登陆页       
                    filterContext.HttpContext.Response.Redirect("/Login/Login");
                }
            }
        }

        protected bool checkLogin()
        {

            if (CookieHelper.GetValue("nfs_UserId") == null || CookieHelper.GetValue("nfs_UserId") == "")
            {
                return false;
            }
            return true;
        }
    }
}